resource "google_compute_instance" "vm" {
  provider     = google-beta
  name         = "<%= ctx[:vars]['vm_name'] %>"
  machine_type = "e2-medium"

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-9"
    }
  }

  network_interface {
    network = "default"
  }
}

resource "google_compute_machine_image" "<%= ctx[:primary_resource_id] %>" {
  provider        = google-beta
  name            = "<%= ctx[:vars]['image_name'] %>"
  source_instance = google_compute_instance.vm.self_link
}
